FROM ubuntu:latest
# 配置清华镜像源
RUN sed -i 's|http://.*archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
    sed -i 's|http://.*security.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
# 安装python3.12
RUN apt update
RUN apt install -y python3.12-full
RUN python3 --version
RUN apt install -y python3-pip
RUN pip3 --version
RUN apt install -y openssh-client
RUN ssh -V
# Create a virtual environment to avoid externally-managed error
RUN apt install -y python3-pip python3-venv python3-pkg-resources  python3-setuptools && \
    python3 -m venv /opt/venv && \
    /opt/venv/bin/pip install --upgrade pip

# Use the virtual environment for installations
ENV PATH="/opt/venv/bin:$PATH"
# RUN pip install pyinstaller pyserial
WORKDIR /app
COPY requirements.txt .
RUN pip3 install -r requirements.txt
RUN pip3 install pyinstaller
COPY ./serial .
RUN pyinstaller --onefile   \
    --hidden-import pkgutil  \
    --hidden-import PyQt5  \
    --hidden-import PyQt5-Qt5  \
    --hidden-import PyQt5_sip  \
    --hidden-import pyserial  \
    --hidden-import pyinstaller  \
    --name SerialTool usb_serial_tool.py

